package com.bittech.springboot.smallfileserver.controller;

import com.bittech.springboot.smallfileserver.service.FileService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

/**
 * Author: secondriver
 * Created: 2018/8/25
 */
@Controller
@RequestMapping
public class FileIndexController {
    
    @Autowired
    private FileService fileService;
    
    @RequestMapping(value = {"/", "/index"})
    public String index(Model model) {
        // 展示最新二十条数据
        model.addAttribute("files", fileService.listFilesByPage(0, 20));
        return "index";
    }
}
